import sys
import zmq
import socket
import struct
import multiprocessing as mp
from typing import Dict, Tuple, Sequence, List
from utils.utils import *
import argparse
import pickle
import time
import numpy as np
import random
from copy import deepcopy
from enum import Enum
import math
import os, shutil
import torch

if __name__ == '__main__':
    mp.set_start_method('spawn')

    # 读取初始化配置
    init_cfgs = process_yaml_cfg(path_to_configs='/root/code/workspace/src/MVS/Configs/', filename='InitConfigs.yaml')
    
    veh_params = init_cfgs.vehicle_init_msg['params']
    recv_ports_head = init_cfgs.decider_ports_cfg['recv_ports_head']
    send_port = init_cfgs.decider_ports_cfg['send_port']
    # 读取决策端配置
    decision_cfg = init_cfgs.decision_cfg
    # 通用配置
    formation_cfg = decision_cfg['formation_cfg']
    general_cfg = decision_cfg['general_cfg']
    algo_cfg = decision_cfg['algo_cfg']
    merge_cfg = MergedConfig()
    merge_cfg = merge_class_attrs(merge_cfg, general_cfg)
    merge_cfg = merge_class_attrs(merge_cfg, algo_cfg)
    
    # # 导入决策算法模块
    agent_mod = __import__(f"algos.{merge_cfg.algo_name}.agent", fromlist=['Agent'])